<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>src\tween\Ease.js - Go2d</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="Go2d" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 1.6.7</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/Class.html">Class</a></li>
                                <li><a href="../classes/Director.html">Director</a></li>
                                <li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
                                <li><a href="../classes/Ease.html">Ease</a></li>
                                <li><a href="../classes/Event.html">Event</a></li>
                                <li><a href="../classes/EventEmitter.html">EventEmitter</a></li>
                                <li><a href="../classes/go2d.html">go2d</a></li>
                                <li><a href="../classes/ImageView.html">ImageView</a></li>
                                <li><a href="../classes/Matrix.html">Matrix</a></li>
                                <li><a href="../classes/ObjectPool.html">ObjectPool</a></li>
                                <li><a href="../classes/ResizeEvent.html">ResizeEvent</a></li>
                                <li><a href="../classes/ResourceLoader.html">ResourceLoader</a></li>
                                <li><a href="../classes/ScrollEvent.html">ScrollEvent</a></li>
                                <li><a href="../classes/ScrollView.html">ScrollView</a></li>
                                <li><a href="../classes/Sprite.html">Sprite</a></li>
                                <li><a href="../classes/Stage.html">Stage</a></li>
                                <li><a href="../classes/TextField.html">TextField</a></li>
                                <li><a href="../classes/TouchEvent.html">TouchEvent</a></li>
                                <li><a href="../classes/Tween.html">Tween</a></li>
                                <li><a href="../classes/URLRequest.html">URLRequest</a></li>
                                <li><a href="../classes/Vector.html">Vector</a></li>
                            </ul>
                
                            <ul id="api-modules" class="apis modules">
                                <li><a href="../modules/go2d.html">go2d</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1 class="file-heading">File: src\tween\Ease.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
/**
 * 缓动函数集合，用于实现不同变化速度类型的动画。
 * @author Lanfei
 * @class Ease
 * @extends Class
 */
var Ease = go2d.Ease = Class.extend({}, {
	/**
	 * 匀速缓动函数
	 * @static
	 * @function linear
	 * @param {number} t 当前时间
	 * @param {number} b 初始值
	 * @param {number} c 变化量
	 * @param {number} d 持续时间
	 * @return {number} 当前值
	 */
	linear: function(t, b, c, d) {
		return c * t / d + b;
	},
	/**
	 * 加速的二次方缓动函数
	 * @static
	 * @function easeInQuad
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInQuad: function(t, b, c, d) {
		return c * (t /= d) * t + b;
	},
	/**
	 * 减速的二次方缓动函数
	 * @static
	 * @function easeOutQuad
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutQuad: function(t, b, c, d) {
		return -c * (t /= d) * (t - 2) + b;
	},
	/**
	 * 先加速后减速的二次方缓动函数
	 * @static
	 * @function easeInOutQuad
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutQuad: function(t, b, c, d) {
		if ((t /= d / 2) &lt; 1) return c / 2 * t * t + b;
		return -c / 2 * ((--t) * (t - 2) - 1) + b;
	},
	/**
	 * 加速的三次方缓动函数
	 * @static
	 * @function easeInCubic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInCubic: function(t, b, c, d) {
		return c * (t /= d) * t * t + b;
	},
	/**
	 * 减速的三次方缓动函数
	 * @static
	 * @function easeOutCubic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutCubic: function(t, b, c, d) {
		return c * ((t = t / d - 1) * t * t + 1) + b;
	},
	/**
	 * 先加速后减速的三次方缓动函数
	 * @static
	 * @function easeInOutCubic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutCubic: function(t, b, c, d) {
		if ((t /= d / 2) &lt; 1) return c / 2 * t * t * t + b;
		return c / 2 * ((t -= 2) * t * t + 2) + b;
	},
	/**
	 * 加速的四次方缓动函数
	 * @static
	 * @function easeInQuart
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInQuart: function(t, b, c, d) {
		return c * (t /= d) * t * t * t + b;
	},
	/**
	 * 减速的四次方缓动函数
	 * @static
	 * @function easeOutQuart
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutQuart: function(t, b, c, d) {
		return -c * ((t = t / d - 1) * t * t * t - 1) + b;
	},
	/**
	 * 先加速后减速的四次方缓动函数
	 * @static
	 * @function easeInOutQuart
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutQuart: function(t, b, c, d) {
		if ((t /= d / 2) &lt; 1) return c / 2 * t * t * t * t + b;
		return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
	},
	/**
	 * 加速的五次方缓动函数
	 * @static
	 * @function easeInQuint
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInQuint: function(t, b, c, d) {
		return c * (t /= d) * t * t * t * t + b;
	},
	/**
	 * 减速的五次方缓动函数
	 * @static
	 * @function easeOutQuint
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutQuint: function(t, b, c, d) {
		return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
	},
	/**
	 * 先加速后减速的五次方缓动函数
	 * @static
	 * @function easeInOutQuint
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutQuint: function(t, b, c, d) {
		if ((t /= d / 2) &lt; 1) return c / 2 * t * t * t * t * t + b;
		return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
	},
	/**
	 * 加速的正弦曲线缓动函数
	 * @static
	 * @function easeInSine
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInSine: function(t, b, c, d) {
		return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
	},
	/**
	 * 减速的正弦曲线缓动函数
	 * @static
	 * @function easeOutSine
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutSine: function(t, b, c, d) {
		return c * Math.sin(t / d * (Math.PI / 2)) + b;
	},
	/**
	 * 先加速后减速的正弦曲线缓动函数
	 * @static
	 * @function easeInOutSine
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutSine: function(t, b, c, d) {
		return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
	},
	/**
	 * 加速的指数曲线缓动函数
	 * @static
	 * @function easeInExpo
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInExpo: function(t, b, c, d) {
		return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
	},
	/**
	 * 减速的指数曲线缓动函数
	 * @static
	 * @function easeOutExpo
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutExpo: function(t, b, c, d) {
		return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
	},
	/**
	 * 先加速后减速的指数曲线缓动函数
	 * @static
	 * @function easeInOutExpo
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutExpo: function(t, b, c, d) {
		if (t === 0) return b;
		if (t === d) return b + c;
		if ((t /= d / 2) &lt; 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
		return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	/**
	 * 加速的圆形曲线缓动函数
	 * @static
	 * @function easeInCirc
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInCirc: function(t, b, c, d) {
		return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
	},
	/**
	 * 减速的圆形曲线缓动函数
	 * @static
	 * @function easeOutCirc
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutCirc: function(t, b, c, d) {
		return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
	},
	/**
	 * 先加速后减速的圆形曲线缓动函数
	 * @static
	 * @function easeInOutCirc
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutCirc: function(t, b, c, d) {
		if ((t /= d / 2) &lt; 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
		return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
	},
	/**
	 * 加速的指数衰减正弦曲线缓动
	 * @static
	 * @function easeInElastic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInElastic: function(t, b, c, d) {
		var s = 1.70158;
		var p = 0;
		var a = c;
		if (t === 0) return b;
		if ((t /= d) === 1) return b + c;
		if (!p) p = d * 0.3;
		if (a &lt; Math.abs(c)) {
			a = c;
			s = p / 4;
		} else s = p / (2 * Math.PI) * Math.asin(c / a);
		return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
	},
	/**
	 * 减速的指数衰减正弦曲线缓动
	 * @static
	 * @function easeOutElastic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutElastic: function(t, b, c, d) {
		var s = 1.70158;
		var p = 0;
		var a = c;
		if (t === 0) return b;
		if ((t /= d) === 1) return b + c;
		if (!p) p = d * 0.3;
		if (a &lt; Math.abs(c)) {
			a = c;
			s = p / 4;
		} else s = p / (2 * Math.PI) * Math.asin(c / a);
		return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
	},
	/**
	 * 先加速后减速的指数衰减正弦曲线缓动
	 * @static
	 * @function easeInOutElastic
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutElastic: function(t, b, c, d) {
		var s = 1.70158;
		var p = 0;
		var a = c;
		if (t === 0) return b;
		if ((t /= d / 2) === 2) return b + c;
		if (!p) p = d * (0.3 * 1.5);
		if (a &lt; Math.abs(c)) {
			a = c;
			s = p / 4;
		} else s = p / (2 * Math.PI) * Math.asin(c / a);
		if (t &lt; 1) return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
		return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b;
	},
	/**
	 * 加速的超范围三次方缓动
	 * @static
	 * @function easeInBack
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInBack: function(t, b, c, d, s) {
		if (s === undefined) s = 1.70158;
		return c * (t /= d) * t * ((s + 1) * t - s) + b;
	},
	/**
	 * 减速的超范围三次方缓动
	 * @static
	 * @function easeOutBack
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutBack: function(t, b, c, d, s) {
		if (s === undefined) s = 1.70158;
		return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
	},
	/**
	 * 先加速后减速的超范围三次方缓动
	 * @static
	 * @function easeInOutBack
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutBack: function(t, b, c, d, s) {
		if (s === undefined) s = 1.70158;
		if ((t /= d / 2) &lt; 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
		return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
	},
	/**
	 * 加速的指数衰减反弹缓动
	 * @static
	 * @function easeInBounce
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInBounce: function(t, b, c, d) {
		return c - jQuery.easing.easeOutBounce(d - t, 0, c, d) + b;
	},
	/**
	 * 减速的指数衰减反弹缓动
	 * @static
	 * @function easeOutBounce
	 * @see 参数及返回值同 {@link linear}
	 */
	easeOutBounce: function(t, b, c, d) {
		if ((t /= d) &lt; (1 / 2.75)) {
			return c * (7.5625 * t * t) + b;
		} else if (t &lt; (2 / 2.75)) {
			return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;
		} else if (t &lt; (2.5 / 2.75)) {
			return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;
		} else {
			return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
		}
	},
	/**
	 * 先加速后减速的指数衰减反弹缓动
	 * @static
	 * @function easeInOutBounce
	 * @see 参数及返回值同 {@link linear}
	 */
	easeInOutBounce: function(t, b, c, d) {
		if (t &lt; d / 2) return jQuery.easing.easeInBounce(t * 2, 0, c, d) * 0.5 + b;
		return jQuery.easing.easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
	}
});

    </pre>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
